from selenium import webdriver
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.common.by import By
from po.base_page import BasePage
from po.login_page import LogoinPage
from po.register_page import Registerpage


class NavBar(BasePage):
    _index_link = By.CSS_SELECTOR, 'li [href="/"]'
    _unread_link = By.CSS_SELECTOR, '[href="/my/messages"]'
    _newman_link = By.CSS_SELECTOR, '[href="/getstart"]'
    _login_link = By.CSS_SELECTOR, 'li [href="/signin"]'
    _register_link = By.CSS_SELECTOR, 'li [href="/signup"]'

    def go_to_index_page(self):
        self._driver.find_element(*self._index_link).click()

    def go_to_unread_page(self):
        self._driver.find_element(*self._unread_link).click()

    def go_to_newman_page(self):
        self._driver.find_element(*self._unread_link).click()

    def go_to_login_page(self):
        self._driver.find_element(*self._login_link).click()
        return LogoinPage(self._driver)

    def go_to_register_page(self):
        self._driver.find_element(*self._register_link).click()
        return Registerpage(self._driver)

# if __name__ == '__main__':
#     driver = webdriver.Chrome(executable_path="E:/chrome驱动/chromedriver.exe")
#     driver.implicitly_wait(6)
#     n = NavBar(driver)
#     driver.get('http://49.233.108.117:3000/getstart')
#     n.go_to_index_page()
